package com.dqyt.app.service;

import com.dqyt.common.utils.UserInfoUtil;
import com.dqyt.khjc.bean.ManufacturerBean;
import com.dqyt.khjc.bean.ModelBean;
import com.dqyt.khjc.bean.ResultMsg;
import com.dqyt.khjc.mapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Service
public class AppModeService {

    @Autowired
    private ModelMapper modelMapper;

    /**
     * 查询型号规格
     * @param request
     * @return
     */
    public ResultMsg getmodels(HttpServletRequest request, long userId, String token,long parentid){
        ResultMsg ret = new ResultMsg(); // 声明一个返回值
        try {
            ret = UserInfoUtil.isAuthori_App(userId, token); // 验证用户是否登录
            if (null != ret) {
                return ret;
            }
            ret = new ResultMsg();
            //查询
            List<ModelBean> data  = modelMapper.getModelByPid(parentid);
            ret.setCode(ResultMsg.SUCESS);
            ret.setMsg("查询成功");
            ret.setData(data);
        }catch (Exception e) {
            ret.setCode(ResultMsg.ERROR);
            ret.setMsg("未知的错误，请稍候再试！");
            e.printStackTrace();
        }
        return ret;
    }

}
